r"""
>>> from datetime import datetime
>>> from random import choice, randint, random
>>> from django.contrib.auth.models import User
>>> from django.contrib.contenttypes.models import ContentType
>>> from rangevoting.models import Vote, VoteSummary 
>>> from rangevoting.rankers import *
>>> from testapp.models import Film

>>> user_ctype = ContentType.objects.get_for_model(User)
>>> film_ctype = ContentType.objects.get_for_model(Film)

>>> batman = Film.objects.create(name="Batman: The Dark Knight")
>>> walle = Film.objects.create(name="Wall-E")
>>> ij = Film.objects.create(name="Indiana Jones 4")
>>> ironman = Film.objects.create(name="Iron Man")
>>> tt = Film.objects.create(name="Tropical Thunder")

>>> matt = User.objects.create(username="matt")
>>> melissa = User.objects.create(username="melissa")
>>> merrick = User.objects.create(username="merrick")
>>> bond = User.objects.create(username="bond")
>>> ezra = User.objects.create(username="ezra")

>>> watchers = [matt, melissa, merrick, bond, ezra]
>>> films = [batman, walle, ij, ironman, tt]

# >>> for f in films:
# ...     vs = VoteSummary.objects.create(
# ...              content_type=film_ctype,
# ...              object_id=f.pk)

>>> VoteSummary.objects.count()
5

# create dated voting records for each movie
# ---
# Batman:
# 3 very high votes, 1 medium
>>> v = Vote.objects.cast_vote(user=matt, obj=batman, score=9.9)
>>> v = Vote.objects.cast_vote(user=melissa, obj=batman, score=10.0)
>>> v = Vote.objects.cast_vote(user=ezra, obj=batman, score=9.5)
>>> v = Vote.objects.cast_vote(user=merrick, obj=batman, score=6.5)

# Wall-E
# 3 mid-range votes, 2 high
>>> v = Vote.objects.cast_vote(user=merrick, obj=walle, score=3.5)
>>> v = Vote.objects.cast_vote(user=ezra, obj=walle, score=2.25)
>>> v = Vote.objects.cast_vote(user=matt, obj=walle, score=9.3)
>>> v = Vote.objects.cast_vote(user=bond, obj=walle, score=10.0)

# Indiana Jones
# 5 mid-range votes
>>> v = Vote.objects.cast_vote(user=bond, obj=ij, score=6.0)
>>> v = Vote.objects.cast_vote(user=merrick, obj=ij, score=4.5)
>>> v = Vote.objects.cast_vote(user=ezra, obj=ij, score=3.5)
>>> v = Vote.objects.cast_vote(user=melissa, obj=ij, score=6.5)
>>> v = Vote.objects.cast_vote(user=matt, obj=ij, score=7.0)

# Iron Man
# 2 strong votes
>>> v = Vote.objects.cast_vote(user=merrick, obj=ironman, score=9.5)
>>> v = Vote.objects.cast_vote(user=bond, obj=ironman, score=8.6)

# Tropical Thunder
# 1 strong vote, 2 weak
>>> v = Vote.objects.cast_vote(user=merrick, obj=tt, score=9.0)
>>> v = Vote.objects.cast_vote(user=ezra, obj=tt, score=3.0)

>>> VoteSummary.objects.rank(model=Film, ranker=AvgRanker)
[<Film: Batman: The Dark Knight>, <Film: Wall-E>, <Film: Indiana Jones 4>, <Film: Iron Man>, <Film: Tropical Thunder>]

>>> VoteSummary.objects.rank(model=Film, ranker=HackerNewsRanker)
[<Film: Batman: The Dark Knight>, <Film: Indiana Jones 4>, <Film: Wall-E>, <Film: Iron Man>, <Film: Tropical Thunder>]

>>> VoteSummary.objects.rank(model=Film, ranker=BayesianRanker)
[<Film: Iron Man>, <Film: Tropical Thunder>, <Film: Batman: The Dark Knight>, <Film: Wall-E>, <Film: Indiana Jones 4>]
"""
